package com.scsj.supermarket.view.activity.ordermodel;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.alibaba.fastjson.JSONObject;
import com.scsj.supermarket.R;
import com.scsj.supermarket.adapter.InterFlowAdapter;
import com.scsj.supermarket.adapter.OrderProcessAdapter;
import com.scsj.supermarket.base.OrderProcessBase;
import com.scsj.supermarket.bean.InterFlowBean;
import com.scsj.supermarket.bean.OrderProcessBean;
import com.scsj.supermarket.presenter.OrderProgressPresenter;
import com.scsj.supermarket.view.activity.baseactivitymodel.BaseActivity;

import java.util.ArrayList;
import java.util.List;

import okhttp3.RequestBody;

public class OrderProcessActivity extends BaseActivity implements OrderProcessBase.IView{

    private OrderProgressPresenter orderProgressPresenter;

    private RecyclerView recyclerView;

    private List<InterFlowBean> flowBeans;
    private OrderProcessAdapter adapter;

    @Override
    protected void createView(Bundle savedInstanceState) {
        setContentView(R.layout.activity_order_process);
        initView();
        initData();
        initListener();

        initToolbar();
        setToolbarTitle("订单流程");
        hasBack(true);
    }

    @Override
    protected void initView() {
        orderProgressPresenter= new OrderProgressPresenter(this);

        recyclerView= findViewById(R.id.order_process_rv);
        recyclerView.setLayoutManager(new LinearLayoutManager(this));
        recyclerView.setNestedScrollingEnabled(false);

    }

    @Override
    protected void initListener() {

    }

    @Override
    protected void initData() {
        flowBeans = new ArrayList<>();
        flowBeans.add(new InterFlowBean("已完成","201-11-12 10:20:20",0));
        flowBeans.add(new InterFlowBean("已完成","201-11-12 10:20:20",0));
        flowBeans.add(new InterFlowBean("已完成","201-11-12 10:20:20",0));
        flowBeans.add(new InterFlowBean("已完成","201-11-12 10:20:20",0));
        flowBeans.add(new InterFlowBean("已完成","201-11-12 10:20:20",0));
        flowBeans.add(new InterFlowBean("已完成","201-11-12 10:20:20",0));
        flowBeans.add(new InterFlowBean("已完成","201-11-12 10:20:20",0));
        flowBeans.add(new InterFlowBean("已完成","201-11-12 10:20:20",0));
        flowBeans.add(new InterFlowBean("已完成","201-11-12 10:20:20",0));
        flowBeans.add(new InterFlowBean("已完成","201-11-12 10:20:20",0));


        adapter = new OrderProcessAdapter(flowBeans);
        recyclerView.setAdapter(adapter);

        JSONObject jsonObject = new JSONObject();
        jsonObject.put("orderId", "180521474964oken");


        RequestBody body = RequestBody.create(okhttp3.MediaType.parse("application/json; charset=utf-8"), jsonObject.toString());
        orderProgressPresenter.deliverData(body);

    }

    @Override
    public void showSuccessMsg(String s, OrderProcessBean orderProcessBean) {

    }

    @Override
    public void showErrorMsg(String s) {

    }
}
